package com.fatgirl.utils
{
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	/**
	 * 定时获取最后一个 
	 * 为了减少一些堆积压力，只取得最后一个来处理
	 * @author iceman
	 * 
	 */
	public class TimingGetLastObj
	{
		private var m_timer:Timer;
		private var m_completeFun:Function;
		private var m_list:Array;
		public function TimingGetLastObj(_delay:Number,_completeFun:Function)
		{
			m_list = new Array;
			m_timer = new Timer(_delay);
			m_completeFun = _completeFun;
			m_timer.addEventListener(TimerEvent.TIMER,timerHandler);
		}
		private function timerHandler(e:TimerEvent):void
		{
			if(m_list.length) m_completeFun.call(null,m_list.pop());
			m_list.length = 0;
			m_timer.stop();
		}
		public function pushObj(_obj:Object):void
		{
			if(!m_timer.running) m_timer.start();
			m_list.length = 0;
			m_list.push(_obj);
			
		}
	}
}